﻿using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entity;
using BLL;
using BLL.Access;
using System.Data;
using Platform.Http;
using Web.Class;
using System;

namespace Web.AuthorizationSystem
{
    public partial class ChaKanRZ : BasePage
    {
        #region 属性

        /// <summary>
        /// 保存结果集
        /// </summary>
        private DataTable dtSource
        {
            get
            {
                return ViewState["dtSource"] as DataTable;
            }
            set
            {
                ViewState["dtSource"] = value;
            }
        }

        #endregion

        #region 变量

       
        /// <summary>
        /// 操作日志BLL
        /// </summary>
        SYS_LOGBLL _SYS_LOGBLL = new SYS_LOGBLL();

        #endregion

        #region 事件

        /// <summary>
        /// 页面加载事件
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            //第一次页面加载
            if (!IsPostBack)
            {
                InitData();
            }
            //每次回发时从内存中取得数据源重新绑定,否则列头无法排序
            this.gvList.DataSource = this.dtSource;
            this.gvList.DataBind();
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            LoadData();
        }
        #endregion

        #region 方法

        /// <summary>
        /// 初始化数据
        /// </summary>
        private void InitData()
        {
            deRZ1.Text = DateTime.Now.AddDays(-5).ToString("yyyy-MM-dd");
            deRZ2.Text = DateTime.Now.ToString("yyyy-MM-dd");
        }

        /// <summary>
        /// 数据加载
        /// </summary>
        private void LoadData()
        {
            string lx = cmbLX.Value.ToString();
            string dt1 = deRZ1.Text;
            string dt2 = deRZ2.Text;
            this.dtSource = _SYS_LOGBLL.SelectSYS_LOGsDynamic(string.Format("s_yewulx='{0}' and D_CAOZUOSJ>=to_date('{1}','yyyy-MM-dd') and D_CAOZUOSJ<=to_date('{2}','yyyy-MM-dd')", lx,dt1,dt2), null);
            this.gvList.DataSource = this.dtSource;
            this.gvList.DataBind();
        }

        #endregion        

       
    }
}